import request from './network'

/**
 * 加入购物车
 * @param {*} token 
 * @param {*} data { goodsId 商品id  count 数量 }
 */
export function addCartApi(token, data) {
  return request({
    url: 'mpms/v1/car/add',
    method: 'post',
    header: {
      Authorization: 'Bearer ' + token
    },
    data
  })
}

/**
 * 查询购物车列表
 */
export function getCartListApi(token) {
  return request({
    url: 'mpms/v1/car/list',
    header: {
      Authorization: 'Bearer ' + token
    }
  })
}

/**
 * 修改商品数量
 * @param {*} data { goodsId 商品id  count 数量 }
 */
export function editCartGoodsNumApi(token, data) {
  return request({
    url: 'mpms/v1/car/edit/num',
    method: 'put',
    header: {
      Authorization: 'Bearer ' + token
    },
    data
  })
}

/**
 * 删除购物车商品
 * @param {*} data { ids 商品id数组 }
 */
export function delCartGoodsApi(token, data) {
  return request({
    url: 'mpms/v1/car?ids=' + data.ids,
    method: 'delete',
    header: {
      Authorization: 'Bearer ' + token
    },
  })
}

